<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>baidu Map</title>
<style type="text/css">
	html{height:100%}
	body{height:100%;margin:0px;padding:0px}
	
	#mapContainer{height:300px; width:500px;}
</style>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.2"></script>
</head>

<body>
	<div id="mapContainer"></div>
	
	<script type="text/javascript">
		
		// 初始化
		function BdMapInit(divContainer){
			window.oBdMap = new BMap.Map(divContainer); // 创建地图实例

			// 基础设置
			oBdMap.enableDragging();//启用地图拖拽事件
			oBdMap.enableScrollWheelZoom();//启用地图滚轮放大缩小
			oBdMap.enableDoubleClickZoom();//启用鼠标双击放大
			oBdMap.enableKeyboard();//启用键盘上下左右键移动地图
			// 控件
			oBdMap.addControl(new BMap.NavigationControl({anchor:BMAP_ANCHOR_TOP_LEFT,type:BMAP_NAVIGATION_CONTROL_LARGE}));//缩放控件
			oBdMap.addControl(new BMap.OverviewMapControl({anchor:BMAP_ANCHOR_BOTTOM_RIGHT,isOpen:1}));//缩略图控件
			oBdMap.addControl(new BMap.ScaleControl({anchor:BMAP_ANCHOR_BOTTOM_LEFT}));//比例尺控件
		}
		
		// 设置地图中心  - 名称
		function BdMapSetCenterByName(sName){
			oBdMap.centerAndZoom(sName);
		}
		
		// 设置地图中心 地图级别 - 点
		function BdMapSetCenterByPoint(fLongitude, fLatitude, nZoom){
			oBdMap.centerAndZoom(new BMap.Point(fLongitude, fLatitude), nZoom);
		}
		
		// 添加多个点  如果一个点嵌套在多个里面
		function BdMapMakersPoint(oMapData){
			for(var i in oMapData){
				(function(){
				var x = i;
				var oPointOne = oMapData[x];
				if (oPointOne.map_longitude != '' && oPointOne.map_latitude != ''){
					
					var Icon_url = "http://www.che1an.com/images/ditu4.png";
					
					var myIcon = new BMap.Icon(Icon_url, new BMap.Size(26, 32));	
					var marker = new BMap.Marker(new BMap.Point(oPointOne.map_longitude,oPointOne.map_latitude), {icon: myIcon});
					
					var sWindowInfo = '<a href="http://www.che1an.com/sshop' + oPointOne.company4_id + '" target="_blank">';
					sWindowInfo += '<img style="float:left;width:80px;height:80px;" class="mimg" src="' + ((oPointOne.xing != '') ? oPointOne.xing : oPointOne.logo) +'" alt="' + oPointOne.shop_name + '" /></a>';
					sWindowInfo += '<div style="float:right;width:200px;/*background-color:#fff;*/"><a href="http://www.che1an.com/sshop' + oPointOne.company4_id + '" target="_blank">';
					sWindowInfo += '<big style="line-height:2;font-size:12px;">' + oPointOne.shop_name + '</big></a><p style="margin:0 0 5px 0;">车易信用指数：' + oPointOne.point + '</p>';
					sWindowInfo += '<strong style="line-height:2;">地址</strong>：' + oPointOne.shop_address + '</div>';
					
					marker.addEventListener("onmouseover", function(){
						this.openInfoWindow(new BMap.InfoWindow(sWindowInfo, {width : 300,height: 120}));  
						
					});
				
					oBdMap.addOverlay(marker);
				}
				})();
			}
		}
		
		BdMapInit("mapContainer");
		BdMapSetCenterByName('上海');//上海嘉定
		//BdMapSetCenterByPoint(116.404, 39.915, 12);
		
		// 添加多个点
		// var oMapData = eval({$oMapData});
		
		var oMapData = eval([{"0":"3583","shop_id":"3583","1":"3583","company4_id":"3583","2":"0","shop_type":"0","3":"\u5c71\u4f51\u6c7d\u8f66\u7f8e\u5bb9\u517b\u62a4\u670d\u52a1\u7ad9","shop_name":"\u5c71\u4f51\u6c7d\u8f66\u7f8e\u5bb9\u517b\u62a4\u670d\u52a1\u7ad9","4":"\u95f8\u5317\u533a\u4e34\u6c7e\u8def266\u53f7\u5e95\u5c42101\u5ba4","shop_address":"\u95f8\u5317\u533a\u4e34\u6c7e\u8def266\u53f7\u5e95\u5c42101\u5ba4","5":"31.317765","map_latitude":"31.317765","6":"121.46308","map_longitude":"121.46308","7":"6428","member_id":"6428","8":"9","point":"9","9":"","xing":"","10":null,"logo":null,"11":"0","is_deposit":"0","12":"3","company4_type":"3","13":"\u5c71\u4f51\u6c7d\u8f66\u7f8e\u5bb9\u517b\u62a4\u670d\u52a1\u7ad9","company_name":"\u5c71\u4f51\u6c7d\u8f66\u7f8e\u5bb9\u517b\u62a4\u670d\u52a1\u7ad9","14":"\u5c71\u4f51","nickname":"\u5c71\u4f51","15":"0","commentNum":"0"},{"0":"3704","shop_id":"3704","1":"3704","company4_id":"3704","2":"0","shop_type":"0","3":"\u4e0a\u6d77\u5e02\u827e\u5609\u6c7d\u914d\u7ecf\u8425\u90e8","shop_name":"\u4e0a\u6d77\u5e02\u827e\u5609\u6c7d\u914d\u7ecf\u8425\u90e8","4":"\u95f8\u5317\u5e73\u9065\u8def156-158\u53f7","shop_address":"\u95f8\u5317\u5e73\u9065\u8def156-158\u53f7","5":"31.296183","map_latitude":"31.296183","6":"121.4311","map_longitude":"121.4311","7":"6828","member_id":"6828","8":"3","point":"3","9":"","xing":"","10":"http:\/\/member.che1an.com\/upload\/attach_6828\/1338878452.jpg","logo":"http:\/\/member.che1an.com\/upload\/attach_6828\/1338878452.jpg","11":"0","is_deposit":"0","12":"3","company4_type":"3","13":"\u4e0a\u6d77\u5e02\u827e\u5609\u6c7d\u914d\u7ecf\u8425\u90e8","company_name":"\u4e0a\u6d77\u5e02\u827e\u5609\u6c7d\u914d\u7ecf\u8425\u90e8","14":"\u827e\u5609","nickname":"\u827e\u5609","15":"0","commentNum":"0"}]);
		BdMapMakersPoint(oMapData);
		
		
		

	
		
	</script>
	
</body>
</html>